package com.dx.as.utils;

import android.app.Service;
import android.content.Context;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Vibrator;

/**
 * Created by jwaoo on 2017/5/26.
 */

public class Utils {
    public static boolean isEmpty(Object object){
        if (object == null) return true;
        if (object.toString().trim().length() == 0 || "null".equals(object.toString().trim().toLowerCase())) return true;
        return false;
    }

    private static Vibrator vib;
    public static void doVibrate(Context context) {
        if (vib == null) vib = (Vibrator) context.getSystemService(Service.VIBRATOR_SERVICE);
        vib.vibrate(200);
    }

    private static Ringtone ringtone;
    public static void startAlarm(Context context){
        if (ringtone == null){
            Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
            if (notification == null) return;
            ringtone = RingtoneManager.getRingtone(context, notification);
        }
        ringtone.play();
    }
}
